package shop;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ProductsManagementScreen implements Screen{
	private Console console;
	
	private Screen createProductScreen;
	private Screen deleteProductScreen;
	private Screen listProductsScreen;

	public void setCreateProductScreen(Screen createProductScreen) {
		this.createProductScreen = createProductScreen;
	}

	public void setListProductsScreen(Screen listProductsScreen) {
		this.listProductsScreen = listProductsScreen;
	}

	public void setDeleteProductScreen(Screen deleteProductScreen) {
		this.deleteProductScreen = deleteProductScreen;
	}
	@Autowired
	public ProductsManagementScreen(Console console) {
		this.console = console;
	}

	public void show(){
		while (true) {
			console.println("\n---------Products Management Screen---------");
			console.println("1: Create a product");
			console.println("2: Delete a product");
			console.println("3: List the products");
			console.println("q: Quit");
			String input = console.readLine();
			if (input.equals("1")) {
				createProductScreen.show();
			} else if (input.equals("2")) {
				deleteProductScreen.show();
			} else if (input.equals("3")) {
				listProductsScreen.show();
			} else if (input.equals("q")) {
				return;
			}
		}
	}
}
